package ca.abubakrsagar.breadboardsim;

import java.awt.BasicStroke;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;

/**
 * A wire object used to link columns together. Creates a wire between two given
 * points.
 * 
 * @author Abubakr & Sagar
 * @since June 14, 2012
 */
public class Wire extends Component {
	private int x, y, x1, y1; // Coordinates for both points on the line.

	/**
	 * Creates a new wire with the given points.
	 * @param x Point 1 x
	 * @param y Point 1 y
	 * @param x1 Point 2 x
	 * @param y1 Point 2 y
	 */
	public Wire(int x, int y, int x1, int y1) {
		
		this.setPreferredSize(new Dimension(x1 - x, y1 - y));
		this.setVisible(true);
		setComponentType(3);

		this.x = x;
		this.y = y;
		this.x1 = x1;
		this.y1 = y1;
	}

	/**
	 * Draws the line by using the Graphics2D object and making the stroke
	 * thicker.
	 */
	public void paintComponent(Graphics g) {
		Graphics2D g2 = (Graphics2D) g;
		g2.setStroke(new BasicStroke(13));
		g2.drawLine(x, y, x1, y1);
	}
}
